package com.quick.android.ui;

import android.app.Activity;
import android.os.Bundle;

import com.quick.android.utils.LogUtils;

public abstract class BaseActivity extends Activity {
    public static final String TAG = BaseActivity.class.getSimpleName();
    private boolean isInitEvent = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LogUtils.d(TAG, "activity_onCreate");
        initViews();
        initData(savedInstanceState);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if (hasFocus && !isInitEvent) {
            loadData();
            isInitEvent = true;
        }
        super.onWindowFocusChanged(hasFocus);
    }

    /**
     * 初始化界面和控件
     */
    public abstract void initViews();

    /**
     * 加载数据
     */
    public abstract void loadData();

    /**
     * 初始化数据
     */
    public abstract void initData(Bundle savedInstanceState);

    @Override
    protected void onPause() {
        super.onPause();
        LogUtils.d(TAG, "activity_onPause");
    }

    @Override
    protected void onResume() {
        super.onResume();
        LogUtils.d(TAG, "activity_onResume");
    }

    @Override
    protected void onStop() {
        super.onStop();
        LogUtils.d(TAG, "activity_onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LogUtils.d(TAG, "activity_onDestroy");
    }
}
